package com.bdqn.tour.servlet.Hqf;

import com.bdqn.tour.pojo.PageInfo;
import com.bdqn.tour.pojo.Scenic;
import com.bdqn.tour.service.HqfSearchMessageService;
import com.bdqn.tour.service.impl.hqfSearchMessageServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/hqfSearch")
public class HqfSearchMessageServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置字符编码格式
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=utf-8");


        //分页参数
        String pageNoStr = req.getParameter("pageNo");
        String pageSizeStr = req.getParameter("pageSize");
        int pageNum = 1;
        int pageSize = 5;
        if(pageNoStr != null && !"".equals(pageNoStr)){
            pageNum = Integer.parseInt(pageNoStr);
        }
        if(pageSizeStr != null && !"".equals(pageSizeStr)){
            pageSize = Integer.parseInt(pageSizeStr);
        }

        //调用业务层查询全部用户信息hqfSearchMessageService
        HqfSearchMessageService searchMessageService = new hqfSearchMessageServiceImpl();

        PageInfo<Scenic> hqfpageInfo = searchMessageService.getPageEmp(pageNum, pageSize);
        //存入session集合
        req.getSession().setAttribute("hqfPageInfo",hqfpageInfo);
        //跳转ScenicManagement.jsp页面
            req.getRequestDispatcher("/ScenicManagement.jsp").forward(req,resp);







    }
}
